package com.sportschain.app.circle;

import android.os.Bundle;
import android.support.v7.widget.RecyclerView;
import android.view.View;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.sportschain.app.R;
import com.sportschain.app.circle.activity.MomentDetailActivity;
import com.sportschain.app.circle.adapter.MomentAdapter;
import com.sportschain.app.circle.bean.MomentBean;
import com.sportschain.app.core.base.BasePagerFragment;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;

/**
 * @author LYZ 2019.01.12
 */
public class CircleListFragment extends BasePagerFragment {

    public static CircleListFragment newInstance() {

        Bundle args = new Bundle();

        CircleListFragment fragment = new CircleListFragment();
        fragment.setArguments(args);
        return fragment;
    }

    @BindView(R.id.moment_rv)
    RecyclerView mMomentRv;

    private MomentAdapter mAdapter;

    @Override
    protected int getLayoutId() {
        return R.layout.fragment_circle_list;
    }

    @Override
    protected void initView(View view, Bundle savedInstanceState) {
        mAdapter = new MomentAdapter();
        mAdapter.bindToRecyclerView(mMomentRv);
        mAdapter.setEmptyView(R.layout.empty_view_layout);
    }

    @Override
    protected void initData() {
        List<MomentBean> data = new ArrayList<>();
        for (int i = 0; i < 12; i++) {
            data.add(new MomentBean());
        }
        mAdapter.setNewData(data);
    }

    @Override
    protected void initListener() {
        mAdapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
            @Override
            public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
                startActivity(MomentDetailActivity.class);
            }
        });
    }
}
